package main

import (
    "facecat"
    "io/ioutil"
    "fmt"
)

var gPaint = facecat.CreatePaint()

func WndProc(hwnd facecat.HWND, msg uint32, wParam, lParam uintptr) (result uintptr) {
    return facecat.WndProcDefault(gPaint, hwnd, msg, wParam, lParam)
}

/*
* 扩展视图
*/
type MyView struct {
    Number int
}

func main() {
    facecat.SetMaxWindow()
    facecat.CreateMainWindow(gPaint, "FaceCat-Go", WndProc)
    xmlStr, _ := ioutil.ReadFile("xml//objectexample.xml")
    button := facecat.FindViewByName("Button", gPaint.Views)

    myView := new(MyView) //创建我的对象
    myView.Number = 100
    var myObject facecat.FCObject = myView //转换为接口
    button.SetObject(myObject) //保存对象
    myView.Number = 200
    var objOut facecat.FCObject = button.GetObject() //获取对象
    if obj, ok := objOut.(*MyView); ok{
        fmt.Println(obj.Number)
    }

    facecat.RenderFaceCat(gPaint, string(xmlStr))
    facecat.ShowWindow(gPaint)
}